package com.hsj.goldstore.mvp.view;

import android.content.Context;
import android.content.Intent;

import android.os.Bundle;
import android.support.v4.content.Loader;
import android.widget.Button;
import android.widget.TextView;

import com.hsj.goldstore.R;
import com.hsj.goldstore.base.BaseMvpActivity;
import com.hsj.goldstore.base.PresenterFactory;
import com.hsj.goldstore.base.PresenterLoader;
import com.hsj.goldstore.mvp.present.MainPresent;

import butterknife.BindView;
import butterknife.OnClick;

public class MainActivity extends BaseMvpActivity<MainPresent, MainView> implements MainView {

    @BindView(R.id.tv_content)
    TextView tvContent;
    @BindView(R.id.btn_get_data)
    Button btnGetData;

    @Override
    protected int getResouseId() {
        return R.layout.activity_main;
    }

    @Override
    protected void initView() {
        presenter.init();
    }

    @Override
    protected void initData() {

    }


    @Override
    public Loader<MainPresent> onCreateLoader(int i, Bundle bundle) {
        return new PresenterLoader<>(this, new PresenterFactory<MainPresent>() {
            @Override
            public MainPresent create() {
                return new MainPresent();
            }
        });
    }

    public static final String DATA_MAIN = "data_main";

    @Override
    public void getIntance(Context context, Bundle bundle) {
        Intent intent = new Intent(context, MainActivity.class);
        intent.putExtra(DATA_MAIN, bundle);
        context.startActivity(intent);
    }

    @Override
    public void showDataResult(String result) {
        tvContent.setText(result);
    }


    @OnClick(R.id.btn_get_data)
    public void onViewClicked() {
        presenter.showStore();
    }


}
